package com.bestdreamer.group;

public class ExHandler {

    public static void main(String[] args){
        Thread.currentThread().setUncaughtExceptionHandler(new MyExHandler());
        int a = 5 / 0;
        System.out.println("程序正常结束");
    }
}

class MyExHandler implements Thread.UncaughtExceptionHandler{

    // 实现 uncaughtException() 方法，该方法将处理线程的未处理异常
    public void uncaughtException(Thread t, Throwable e) {
        System.out.println(t + "线程出现了异常：" + e);
    }
}